<!DOCTYPE html>
<html lang="en">
  <head>
    <?php echo Yaf_View_Simple::render('header.phtml'); ?>
    <script type="text/javascript">
     var app = {
         article_rows : <?php echo $count[0]; ?>,
     }
    </script>
    
  </head>
  <body">
    <?php echo Yaf_View_Simple::render('nav.phtml'); ?>
    <div class="container">
      
      <div class="col-lg-12">
        <div class="page-header">
          <h2>Search "<?php echo $keyword; ?>"</h2>
        </div>
        <div class="search-content">
          <?php if(empty($articles)){ ?>
          <h3>No result</h3>
          <?php }else{ ?>
            <?php foreach($articles as $value) { ?>
            <h2><a href="/index/article/post?id=<?php echo $value['id']; ?>"><?php echo $value['title']; ?></a></h2>
            <div class="search-description"><?php echo $value['description']; ?></div>
            <div class="search-article-info">
              <span><?php echo $value['author']; ?></span>
              <span><?php echo $value['create_time']; ?></span>
            </div>
            <?php }} ?>
        </div>
        <div class="pagination" id ="pagination">
          <ul>
          </ul>
        </div>
      </div>
    </div>

    <footer class="footer">
      <?php echo Yaf_View_Simple::render('footer.phtml'); ?>
    </footer>
    <script>

    </script>
    <!-- <script src="/asset/index/js/pagination.js" type="text/javascript"></script> -->
    <script src="/asset/index/js/ajaxpage.js" type="text/javascript"></script>
    <script type="text/javascript">
     ;(function(){
         var bind = function(){
             var pagination = $("#pagination");
             var _a = pagination.find("li a");
             var keyword = '<?php echo $keyword; ?>';
             _a.on('click',function(){
                 var page = $(this).text();
                 page = parseInt(page);
                 if(page > 1){
                     page = (page-1)*10;
                 }
                 $.ajax({
                     type:"get",
                     url :"/index/article/page",
                     data:{
                         page : page,
                         keyword:keyword,
                     },
                     success:function(e){
                         $(".search-content").html(e)
                         // console.log(e);
                     },
                     dataType: 'text',
                 });            
             })

         }
         bind();
         
     }())
    </script>
  </body>
</html>

